fix: backport device mode and system-wide conf#1663
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a "device passthrough" mode for the container runtime, allowing the entire host /dev directory to be bind-mounted into the sandbox. Key changes include updating the API schema to include a device_mode option, adding a --device-mode flag to the CLI, and refactoring the configuration loading logic to support system-wide configurations in addition to user-specific ones. The OCI configuration builder was also updated to handle the passthrough logic and ensure /run/udev is mounted. Review feedback identifies a logic error in bindDevNode that could lead to incorrect device node mounting when passthrough is enabled, as well as a potential type mismatch in the refactored configuration loading functions that might cause compilation issues.
| if (!devPassthru && devNodeMount) { | ||
| devNodeMount->emplace_back(std::move(m)); | ||
| } else { | ||
| devNodeMount = { std::move(m) }; |
There was a problem hiding this comment.
The logic in bindDevNode is incorrect when devPassthru is true. The condition !devPassthru && devNodeMount will always be false, causing devNodeMount to be reset to a single-element vector on every iteration of the loop, effectively only keeping the last matching device node. If the intention is to skip individual node mounts when passthrough is enabled (since the entire /dev is already bind-mounted), the logic should be corrected to avoid overwriting the list.
if (!devPassthru) {
if (devNodeMount) {
devNodeMount->emplace_back(std::move(m));
} else {
devNodeMount = { std::move(m) };
}
}| auto result = linglong::utils::loadRuntimeConfig(configPath); | ||
| if (!result) { | ||
| return LINGLONG_ERR(result); | ||
| return linglong::utils::loadRuntimeConfig(configPath); |
There was a problem hiding this comment.
Potential type mismatch in return statement. linglong::utils::loadRuntimeConfig(configPath) returns Result<RuntimeConfigure>, but the function loadRuntimeConfigFromDir is declared to return Result<std::optional<RuntimeConfigure>>. Unless the Result template supports implicit conversion between these types, this may cause a compilation error. It is safer to explicitly handle the result as done in the previous implementation.
auto result = linglong::utils::loadRuntimeConfig(configPath);
if (!result) {
return LINGLONG_ERR(result);
}
return std::move(result).value();
deepin pr auto review这份代码变更主要实现了为沙箱/容器运行环境添加 以下是对该 diff 的详细代码审查意见,分为语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结代码整体结构清晰,重构合理。最核心的问题在于安全层面: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengbo11, reddevillg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
7d4ce45
into
OpenAtom-Linyaps:release/1.12
ca6a44e feat: add device passthru mode
c7f3a69 feat: support system-wide runtime configuration